﻿using Pattern21迭代器模式.Interface;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Pattern21迭代器模式.Models
{
    /// <summary>
    /// 具体集合类
    /// </summary>
    public class ConcreteAggregate<T> : IAggregate<T>
    {
        private readonly List<T> _list;

        public ConcreteAggregate()
        {
            _list = new List<T>();
        }

        public void Add(T item)
        {
            _list.Add(item);
        }
        public IIterator<T> Create()
        {
            return new ConcreteIterator<T>(_list);
        }
    }
}
